# @Author:黄景涛
# @Date: 2023/10/24

from hamcrest import *


def equal_assert(expect, actual):
    assert_that(actual, equal_to(expect), reason='断言失败原因')


if __name__ == '__main__':
    l = [(1, 1), (1, 2), ('1', 1), ('预期结果', '实际结果'), ([1, 2, 3], [1, 2, 3]), ([1, 2, 3], [1, 2]),
         ({'k1': 1, 'k2': 2}, {'k1': 1, 'k2': 2}), ({'k1': 1, 'k2': 2}, {'k2': 2, 'k1': 1}), ({'k1': 1, 'k2': 2}, {'k1': 1})]

    for group in l:
        ex, ac = group
        try:
            equal_assert(ex, ac)
            print(f'{group}断言成功')
        except AssertionError as e:
            print(f'{group}断言失败, {e}')

